import { observable, action, runInAction, configure } from 'mobx'
import { getCommentList, deleteComment } from './CommentServ'
import { message} from 'antd' 

configure({
	enforceActions: 'observed'
})

class Comment {
	// 评论列表
	@observable commentList = []
	// 控制对话框的显示与隐藏
	@observable visible = false

	@action
	doGetCommentList() {
		getCommentList().then(res => {
			runInAction(() => {
				this.commentList = res.data.commentList
			})
		}, (err) => {
			console.log(err)
		})
	}

	@action
	doDeleteComment(_id, time, isSon) {
		deleteComment({
			_id,
			time,
			isSon
		}).then(res => {
			console.log(res)
			if(res.resultCode == '0') {
				message.success('删除成功')
				this.doGetCommentList()
			}
		})
	}

}

export default Comment